<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 李邦琦 <1536549251@qq.com>
// +----------------------------------------------------------------------

namespace app\crm\model;
use think\Db;
use think\Model;
use think\Cache;
use think\Loader;

class Log extends Model
{
    /**
     * 日志表信息
     * @var array
     */
    protected $tables = [
        'vip' => [
            'name' => 'log_vip',
            'table' => 'xy_log_vip',
            'fields' => ['id', 'username', 'action', 'createtime'],
        ],

        'order' => [
            'name' => 'log_order',
            'table' => 'xy_log_order',
            'fields' => ['id', 'username', 'action', 'createtime'],
        ],

        'shop' => [
            'name' => 'log_shop',
            'table' => 'xy_log_shop',
            'fields' => ['id', 'username', 'action', 'createtime'],
        ],

        'sys' => [
            'name' => 'log_sys',
            'table' => 'xy_log_sys',
            'fields' => ['id', 'username', 'action', 'createtime'],
        ],

        'mob' => [
            'name' => 'log_mob',
            'table' => 'xy_log_mob',
            'fields' => ['id', 'username', 'action', 'createtime'],
        ],
    ];


    /**
     * 增加操作日志
     * @param  string $key  数据表数组键
     * @param  array  $data 日志数据
     */
    public function insertLog ($key, $data)
    {
        Db::name($this->$tables[$key]['name'])->insert($data);
    }


}